package com.example.ch9;

import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class UerForeachServlet
 */
public class UerForeachServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UerForeachServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String[] movieList = {"Amelie", "Return of the King", "Mean Girls", "Lost"};
		request.setAttribute("movieList", movieList);
		
		String[] movies0 = {"movie00", "movie01", "movie02"};
		String[] movies1 = {"movie10", "movie11", "movie12"};
		ArrayList movies = new ArrayList();
		movies.add(movies0);
		movies.add(movies1);
		request.setAttribute("movies", movies);
		
		RequestDispatcher dispatcher = request.getRequestDispatcher("forEachPage.jsp");
		dispatcher.forward(request, response);
	}

}
